GtkFileChooser: Don't crash if invisible files are deleted
authorMatthias Clasen <mclasen@redhat.com>
Fri, 12 Dec 2014 03:52:59 +0000 (22:52 -0500)
committerMatthias Clasen <mclasen@redhat.com>
Fri, 12 Dec 2014 03:57:37 +0000 (22:57 -0500)
This is a crash that has been around for a long time, as
can be seen here:
https://bugzilla.redhat.com/show_bug.cgi?id=1048388
https://bugzilla.redhat.com/show_bug.cgi?id=984375
https://bugzilla.redhat.com/show_bug.cgi?id=1159015
https://bugzilla.redhat.com/show_bug.cgi?id=1059187
https://bugzilla.redhat.com/show_bug.cgi?id=1122172
https://bugzilla.redhat.com/show_bug.cgi?id=1016895
https://bugzilla.redhat.com/show_bug.cgi?id=1133235
https://bugzilla.redhat.com/show_bug.cgi?id=1077500
https://bugzilla.redhat.com/show_bug.cgi?id=1054378
https://bugzilla.redhat.com/show_bug.cgi?id=1173212

Fix suggested by Benjamin Otte.

gtk/gtkfilesystemmodel.c

index 85a282eba1d2ba95538c5d7187ba060027eb990d..621f4a7f15ce1d84ef1b9b424a64b3b68d6c2454 100644 (file)
@@ -1886,6 +1886,7 @@ remove_file (GtkFileSystemModel *model,
             GFile              *file)
 {
   FileModelNode *node;
+  gboolean was_visible;
   guint id;
   guint row;
 
@@ -1897,6 +1898,7 @@ remove_file (GtkFileSystemModel *model,
     return;
 
   node = get_node (model, id);
+  was_visible = node->visible;
   row = node_get_tree_row (model, id);
 
   node_invalidate_index (model, id);
@@ -1912,7 +1914,8 @@ remove_file (GtkFileSystemModel *model,
 
   /* We don't need to resort, as removing a row doesn't change the sorting order of the other rows */
 
-  emit_row_deleted_for_row (model, row);
+  if (was_visible)
+    emit_row_deleted_for_row (model, row);
 }
 
 /**